<?xml version="1.0" encoding="UTF-8"?>
<ui:composition template="/WEB-INF/templates/portalTemplate.xhtml"
	xmlns="http://www.w3.org/1999/xhtml"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:a4j="http://richfaces.org/a4j"
	xmlns:rich="http://richfaces.org/rich"
	xmlns:my="http://java.sun.com/jsf/composite/components">
	<ui:define name="content">
		<ui:include src="/components/antiBrowserHistory.xhtml" />
		<rich:panel header="Stan postępów ucznia">
			<h:messages infoClass="messageInfo" warnClass="messageWarn" />
			<h:panelGroup>
				<h:outputText value="#{studentProgresBrowser.student.fullName}"
					class="blueHeader" />
				<h:panelGrid columns="1">
					<h:panelGroup>
						<h:outputLabel value="E-mail:" styleClass="label" />
						<h:outputText value="#{studentProgresBrowser.student.email}" />
					</h:panelGroup>
					<h:panelGroup>
						<h:outputLabel value="Województwo:" styleClass="label" />
						<h:outputText value="#{studentProgresBrowser.student.province}" />
					</h:panelGroup>
					<h:panelGroup>
						<h:outputLabel value="Miejscowość:" styleClass="label" />
						<h:outputText value="#{studentProgresBrowser.student.place}" />
					</h:panelGroup>

				</h:panelGrid>
			</h:panelGroup>

			<h:form>

				<rich:dataGrid id="coursesList"
					value="#{studentProgresBrowser.courses}" var="_course" columns="1">

					<rich:collapsiblePanel switchType="client"
						header="Kurs #{_course.number} : #{_course.title}">
						<rich:dataTable id="table" value="#{_course.lessons}" var="_l"
							keepSaved="true">
							<rich:column width="30" style="width:30px;">
								<f:facet name="header">Nr</f:facet>
								<h:outputText value="#{_l.number}" />
							</rich:column>
							<rich:column width="300" style="width:300px;">
								<f:facet name="header">Opis</f:facet>
								<h:outputText value="#{_l.shortIntroduction}" />
							</rich:column>
							<rich:column width="100" style="width:100px;">
								<f:facet name="header">Stan</f:facet>
								<h:outputText
									value="#{studentProgresBrowser.getState(_l.id, studentProgresBrowser.student.id)}" />
							</rich:column>
							<rich:column width="100" style="width:10px;">
								<f:facet name="header">Operacje</f:facet>

								<a4j:commandButton
									action="#{studentProgresBrowser.goToLesson()}" value="Podgląd"
									styleClass="buttonSmall" style="width:110px;">
									<a4j:param value="#{_l.id}"
										assignTo="#{studentProgresBrowser.lessonId}" />
									<a4j:param value="#{studentProgresBrowser.student.id}"
										assignTo="#{studentProgresBrowser.studentId}" />
									<a4j:ajax render="table" event="action" />
								</a4j:commandButton>

								<a4j:commandButton id="button"
									action="#{studentProgresBrowser.shareLesson()}"
									value="Udostępnij lekcję"
									disabled="#{studentProgresBrowser.getState(_l.id, studentProgresBrowser.student.id) ne 'Nieudostępniona'}"
									styleClass="buttonSmall" render="@page" execute="@this"
									style="width:110px;">
									<a4j:param value="#{_l.id}"
										assignTo="#{studentProgresBrowser.lessonId}" />
									<a4j:param value="#{studentProgresBrowser.student.id}"
										assignTo="#{studentProgresBrowser.studentId}" />
									<a4j:ajax render="table" event="action" />
								</a4j:commandButton>

								<a4j:commandButton
									action="#{studentProgresBrowser.goToLesson()}"
									disabled="#{!studentProgresBrowser.getState(_l.id, studentProgresBrowser.student.id).contains('Wysłana do spr.')}"
									value="Sprawdź lekcję" styleClass="buttonSmall"
									style="width:110px;">
									<a4j:param value="#{_l.id}"
										assignTo="#{studentProgresBrowser.lessonId}" />
									<a4j:param value="#{studentProgresBrowser.student.id}"
										assignTo="#{studentProgresBrowser.studentId}" />
									<a4j:ajax render="table" event="action" />
								</a4j:commandButton>




							</rich:column>
						</rich:dataTable>
					</rich:collapsiblePanel>

				</rich:dataGrid>
			</h:form>
		</rich:panel>
	</ui:define>
</ui:composition>
